package com.jie.controller;



import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jie.entity.BodyDimension;
import com.jie.response.RespBean;
import com.jie.service.IBodyDimensionService;
import com.jie.vo.BodyDimensionVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 身体维度表 前端控制器
 * </p>
 *
 * @author jie
 * @since 2024-04-20
 */
@RestController
@RequestMapping("/body")
@Api(tags = "身体维度模块")
public class BodyDimensionController {
    @Autowired
    private IBodyDimensionService iBodyDimensionService;
    //更新当前自己的身高体重 腰围 胸围等等
    @ApiOperation("用户更新自己的身体数据")
    @PostMapping("/update/body-info")
    public RespBean<?> updateBodyInfo(@RequestBody BodyDimensionVO bodyDimensionVO){
        Boolean flag=iBodyDimensionService.updateBodyInfo(bodyDimensionVO);
        return RespBean.success("更新成功",flag);
    }
    @ApiOperation("根据用户id查询身体数据")
    @GetMapping("/getBodyInfo/{userId}")
    public RespBean<?> getBodyInfo(@PathVariable("userId") Integer userId){
        BodyDimension bodyDimensionInfo = iBodyDimensionService.getOne(new LambdaQueryWrapper<BodyDimension>().eq(BodyDimension::getUserId, userId));
        return RespBean.success("查看身体数据",bodyDimensionInfo);
    }
}

